package com.gudy.engine.bean.orderbook;

import com.gudy.engine.bean.command.CmdResultCode;
import com.gudy.engine.bean.command.RbCmd;
import thirdpart.hq.L1MarketData;

import static thirdpart.hq.L1MarketData.L1_SIZE;

public interface IOrderBook {

    //1.新增委托
   CmdResultCode newOrder(RbCmd cmd);

    //2.撤单
    CmdResultCode cancelOrder(RbCmd cmd);

    //3.查询行情快照
    default L1MarketData getL1MarketDataSnapshot(){
        final int buySize = limitBuyBucketSize(L1_SIZE);
        final int sellSize = limitSellBucketSize(L1_SIZE);
        final L1MarketData marketData = new L1MarketData(buySize, sellSize);
        fillBuys(buySize,marketData);
        fillSells(sellSize,marketData);
        fillCode(marketData);
        marketData.timestamp=System.currentTimeMillis();
        return marketData;
    }

    void fillCode(L1MarketData marketData);

    void fillSells(int sellSize, L1MarketData marketData);

    void fillBuys(int buySize, L1MarketData marketData);

    int limitSellBucketSize(int maxSize);

    int limitBuyBucketSize(int maxSize);

    //4.TODO 初始化枚举

}
